package com.tensquare.article.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.tensquare.article.po.Article;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface ArticleRepository extends JpaRepository<Article,String>,JpaSpecificationExecutor<Article>{
    /**
     * 根据id 添加 指定状态
     */
    @Query(value = "UPDATE tb_article SET state = ?2 WHERE id = ?1", nativeQuery = true)
    @Modifying
    public void updateStateById(String id , String state);

    /**
     * 根据id点赞
     */
    @Query(value = "UPDATE tb_article SET thumbup = thumbup + 1 WHERE id = ?1", nativeQuery = true)
    @Modifying
    public  void updateThumbupById(String id);
}
